<template>
  <div style="width: 100%; height: 100%">
    <div class="quan">
      <img class="beijin" src="../assets/dlimage/beijin2x.png" alt="" />
      <div class="dlleft">
        <div class="kuang1">
          <p class="sx">双线质量管控体</p>
          <p class="lq">力求每件产品、每个细节都尽善尽美</p>
          <p class="zy">够专业 &nbsp; 才放心</p>
        </div>
        <div class="kuang2"></div>
      </div>
      <div class="dlright">
        <p class="huanyin">欢迎使用</p>
        <p class="xitong">系统登陆</p>
        <el-form
          :model="ruleForm"
          :rules="rules"
          hide-required-asterisk
          ref="ruleForm"
          label-width="85px"
          class="demo-ruleForm"
        >
          <el-form-item label="用户名" prop="name" class="yonghuming">
            <el-input
              v-model="ruleForm.name"
              style="width: 240px"
              placeholder="请输入用户名"
            >
              <img
                slot="prefix"
                src="../assets/dlimage/yonghu.png"
                alt=""
                class="yonghutu"
              />
            </el-input>
          </el-form-item>
          <el-form-item label="密码" prop="pass" class="mima">
            <el-input
              type="password"
              v-model="ruleForm.pass"
              style="width: 240px"
              placeholder="请输入密码"
              show-password
            >
              <img
                slot="prefix"
                src="../assets/dlimage/mima.png"
                alt=""
                class="mimatu"
              />
            </el-input>
          </el-form-item>
        </el-form>
        <!-- <span class="yonghuming">用户名</span>
            <input type="text" class="yonghu">
            <img src="../assets/dlimage/yonghu.png" alt="" class="yonghutu"> -->
        <!-- <span class="mima">密码</span>
            <input type="text" class="mimashuru">
            <img src="../assets/dlimage/mima.png" alt="" class="mimatu"> -->
        <div class="denglu" @click="submitForm">登录</div>
      </div>
      <p class="banquan">
        All Rights Reserved ©2021 版权所有 &nbsp; &nbsp; &nbsp; &nbsp; ｜&nbsp;
        粤ICP备18069755号
      </p>
      <img class="di" src="../assets/dlimage/ORDER2x2.png" alt="" />
      <img class="shang" src="../assets/dlimage/ORDER2x.png" alt="" />
    </div>
  </div>
</template>

<script>
//import HelloWorld from './components/HelloWorld.vue'
import md5 from 'js-md5'
// import axios from 'axios'
// console.log(axios)
export default {
  name: "login",
  props: {
    msg: String,
  },

  data() {
    return {
      ruleForm: {
        name: "",
        pass: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      rules: {
        name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        pass: [
          { required: true, message: "请输入密码", trigger: "blur" },
          {
            min: 6,
            max: 12,
            message: "长度在 6 到 12 个字符",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.$http({
            url:'/login',
            method:'POST',
            data:{
              userName:this.ruleForm.name,
              passWord:md5(this.ruleForm.pass),
              platform:'Web'
            }
          }).then(res => {
            if(!res.errorMsg){
              localStorage.setItem('token',res.token)
              localStorage.setItem('user',JSON.stringify(res))
              this.$router.push('/index')
            }
          })
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
  created() {
    
  },
  mounted() {},
};
</script>

<style scoped>
@import "../assets/dlcss/reset.css";
@import "../assets/dlcss/denglu.css";
</style>
